package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.security.pkcs11.Secmod;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/findAll")
    public String doFindAll(Model model){
        List<User> list = userService.findAll();
        model.addAttribute("userList", list);
        return "userList";
    }

    @RequestMapping("/doAjaxFindAll")
    @ResponseBody
    public List<User> doAjaxFindAll(){
        List<User> list = userService.findAll();
        return list;
    }
    @RequestMapping("/doAjax")
    public String doAjax(){
        return "ajax";
    }
}
